<?php
// $Id: Object.php 27 2010-11-16 12:49:54Z mjohnson60@gmail.com $


/**
 * Enter description here ...
 * 
 * @author Mark Phillip Johnson
 * @version 1.0
 * @copyright Copyright (c) 2010, markjohnson
 * @license http://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
 *
 */
class Object
{

	/**
	 * Enter description here ...
	 * 
	 */
	public function __construct()
	{
	
	}

	/**
	 * Enter description here ...
	 * 
	 * @return string
	 */
	public function parentClass()
	{
		return get_parent_class(get_called_class());
	}

	/**
	 * Enter description here ...
	 * 
	 * @return string
	 */
	public function getClass()
	{
		return get_class(get_called_class());
	}

	/**
	 * Enter description here ...
	 * 
	 * @param string $class
	 * @return boolean
	 */
	public function isSubclassOf($class)
	{
		return is_subclass_of($this, $class);
	}

	/**
	 * Enter description here ...
	 * 
	 * @param string $method
	 * @return boolean
	 */
	public function instancesRespondToMethod(string $method)
	{
		$class = get_called_class();
		$methods = get_class_methods(new $class());
		return in_array($method, $methods);
	}

	/**
	 * Enter description here ...
	 * 
	 * @return string
	 */
	public function toString()
	{
		return get_class($this);
	}

	/**
	 * Enter description here ...
	 * 
	 * @return string
	 */
	public function hashValue()
	{
		return spl_object_hash($this);
	}

	/**
	 * Enter description here ...
	 * 
	 * @param int $status
	 */
	public function _stop($status = 0)
	{
		exit($status);
	}

	/**
	 * Allows setting of multiple properties of the object in a single line of code.  Will only set 
	 * properties that are part of a class declaration.
	 *
	 * @param array $properties An associative array containing properties and corresponding values.
	 * @return void
	 * @access protected
	 */
	public function _set($properties = array())
	{
		if (is_array($properties) && !empty($properties))
		{
			$vars = get_object_vars($this);
			foreach ($properties as $key => $val)
			{
				if (array_key_exists($key, $vars))
				{
					$this->{$key} = $val;
				}
			}
		}
	}

	/**
	 * Enter description here ...
	 * 
	 * @param unknown_type $msg
	 * @param unknown_type $variables
	 * @param unknown_type $type
	 * @param unknown_type $link
	 */
	public function log($msg, $variables = array(), $type = LOG_ERROR, $link = '')
	{
		if (!class_exists('Log', FALSE))
		{
			Loader::import('Log');
		}
		
		Log::log($msg, $variables, $type, $link);
	}
}